package com.ojtest.demo;

import java.util.HashMap;

public class code2 {
    public static void main(String[] args) {

    }
    public static int[] twoSum(int[] nums, int target) {
        int n = nums.length;
        HashMap<Integer,Integer> map = new HashMap<>();
        map.put(target-nums[0],0);

        for(int i = 1;i<n;i++){
            if(map.containsKey(nums[i])) return new int[]{map.get(nums[i]),i};
            map.put(target-nums[i],i);
        }

        return new int[]{-1,-1};
    }
}
